﻿using Adnc.Infra.EventBus;
using System;
using System.Collections.Generic;
using System.Text;

namespace Adnc.Shared.Events
{
    /// <summary>
    /// 修改商品库存
    /// </summary>
    [Serializable]
    public class ProductInventoryChangeEvent : BaseEvent<ProductInventoryChangeEvent.EventData>
    {
        public ProductInventoryChangeEvent()
        { 
        }

        public ProductInventoryChangeEvent(long id, EventData eventData, string eventSource) : base(id, eventData, eventSource)
        {
        }


        public class EventData
        {
            /// <summary>
            /// 改变类型 1：购买改变 -1:订单回滚改变
            /// </summary>
            public int Type { get; set; }

            /// <summary>
            /// 商品
            /// </summary>
            public IEnumerable<Change> Product { get; set; }

            /// <summary>
            /// 赠品
            /// </summary>
            public IEnumerable<Change> Gift { get; set; }
        }

        /// <summary>
        /// 商品信息
        /// </summary>
        public class Change
        {
            /// <summary>
            /// 主键
            /// </summary>
            public long Id { get; set; }

            /// <summary>
            /// 数量
            /// </summary>
            public int Num { get; set; }
        }
    }
}
